
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<span style="font-size:18px;">
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="attendance/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="attendance/css/commonly-used-show.css" />
    <script type="text/javascript" src="attendance/js/jquery.min.js"></script>
    <script type="text/javascript" src="attendance/js/bootstrap.js" ></script>


    <link rel="stylesheet" type="text/css" href="attendance/css/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="attendance/css/modal.css" />
    <script type="text/javascript" src="attendance/js/modal.js" ></script>

    <title>老师信息管理</title>

    <style type="text/css">
        td, th {
            text-align: center;
        }
    </style>

</head>

<body class="mybody">


<jsp:include page="theTopMenuAdmin.jsp" />


<div class="container-fluid">
    <div class="row">


        <div class="col-md-12">
            <div class="col-md-12">
                    <div class="panel panel-primary">
                        <div class="panel-body">

                            <div>
    <h3 style="text-align: center">用户信息列表</h3>
    <table border="1" class="table table-bordered table-hover">
        <tr class="success">
            <th>序号</th>
            <th>账号</th>
            <th>用户类型</th>
            <th>编号</th>
            <th>创建时间</th>
            <th>姓名</th>
            <th>性别</th>
            <th>地址</th>
            <th>联系方式</th>
            <th>操作</th>
        </tr>


        <c:forEach items="${allthacher}" var="user" varStatus="xh">
            <tr>
                <td>${xh.count}</td>
                <td>${user.userLoginName}</td>
                <c:if test="${user.userLevel == 1}">
                    <td>${"教师"}</td>
                </c:if>
                <td>${user.createUserId}</td>
                <td>${user.createTime}</td>
                <td>${user.userName}</td>
                <td>${user.userSex}</td>
                <td>${user.userAddress}</td>
                <td>${user.userTel}</td>
                <td><a class="btn btn-default btn-sm" href="${pageContext.request.contextPath}/thstuUpdateUsers?id=${user.id}">修改</a>&nbsp;<a class="btn btn-default btn-sm" href="#" onclick="deleteUser('${user.id}')">删除</a></td>
            </tr>
        </c:forEach>

    </table>
                                <div class="text-center">
            <label id="user_null" style="color: red"></label>
        </div>
</div>

                        </div>
                    </div>
                </div>
        </div>



    </div>

 </div>



<script type="text/javascript">
    var userdt = JSON.parse(sessionStorage.getItem("user"));
    var userNull = document.getElementById("user_null");
    if (userdt.result.userName != null){
        $("#usname").text(userdt.result.userName);
    }else {
        $("#usname").text(userdt.result.userLoginName);
    }

    function deleteUser(datees){
        var mModal2 = new mModal({
            top: "40vh",
            content: "你确定要删除此项？",
            confirm: function () {
                deleteUser1(datees);
                mModal2.close();
            },
            cancel: function () {
            }
        });

        mModal2.renderDom();


    }

    function deleteUser1(id){
        var postUrl = "${pageContext.request.contextPath}/member/deleteByPrimaryKey";
        var str = {
            "id": id
        };
        $.ajax({
            type:"post",
            url:postUrl,
            headers: {
                "Content-Type":"application/json"
            },
            data:JSON.stringify(str),
            contentType: "application/json; charset=utf-8",
            dataType:"json",
            success:function(data){
                if (data.status == "0"){
                    userNull.innerHTML = data.msg;
                }else {
                    //alert("删除用户成功")
                    location.reload();
                }

            },
            error:function(xhr,state,errorThrown){
                //alert("发生网络错误，错误码为：" + xhr.status)
                location.href = "${pageContext.request.contextPath}/error";
            }
        });
    }

</script>

</body>
</html>
</span>